package com.jintu.portal.repository.mysql.dao;

import com.jintu.portal.repository.mysql.mapper.ParamDataSourceMapper;
import com.jintu.portal.pojo.entity.mysql.ParamDataSource;
import com.jintu.portal.pojo.exception.DaoException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author very
 */
@Slf4j
@Repository("paramDataSourceDao")
public class ParamDataSourceDao {

    @Resource
    private ParamDataSourceMapper paramDataSourceMapper;

    public List<ParamDataSource> queryParamDataSourceByScoreId(Integer scoreId) throws DaoException {
        try {
            return paramDataSourceMapper.queryParamDataSourceByScoreId(scoreId);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new DaoException(e.getMessage());
        }
    }

    public List<ParamDataSource> queryParamDataSourceByRuleChainId(Integer ruleChainId) throws DaoException {
        try {
            return paramDataSourceMapper.queryParamDataSourceByRuleChainId(ruleChainId);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new DaoException(e.getMessage());
        }
    }

    public ParamDataSource queryParamDataSourceByCode(String paramDataSourceCode) throws DaoException {
        try {
            return paramDataSourceMapper.queryParamDataSourceByCode(paramDataSourceCode);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new DaoException(e.getMessage());
        }
    }
}
